package com.topcoder.srm518;

public class CoinReversing {
	public double expectedHeads(int N, int[] a) {
		double eHead = N;
		double eTail = 0.0;
		for (int i=0; i<a.length; i++) {
			double flip = 1.0 * a[i] / N;
			eHead = flip * eTail + (1 - flip) * eHead;
			eTail = N - eHead;
		}
		return eHead;
	}
}
